<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Stimulus360.Controllers.Ideas.IdeaFeedbackSubmissionViewModel>" %>

<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="Stimulus360.Controllers" %>
<%@ Import Namespace="Stimulus360.Models.Data" %>
<%@ Import Namespace="Stimulus360.Services" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <%
        double ratingToBeShown = 0;
        string header = "Submit Feedback";

        if (Model.AlreadySubmitted)
        {
            ratingToBeShown = (double)(Model.Feedback.Rating);
            header = Stimulus360.Resources.Stimulus360.Rule_DuplicateFeedback;
        }
        else
        {
            ratingToBeShown = 0;
        }
        RatingViewModel ratingViewModel = new RatingViewModel { Id = Model.IdeaSummary.IdeaId, AverageRating = ratingToBeShown, IsDisabled = Model.AlreadySubmitted, IdeaId = Model.IdeaSummary.IdeaId };
    %>
    <%=Html.Hidden("IsReadOnly", Model.AlreadySubmitted)%>
    <%Html.RenderPartial("IdeaDetailLeftNavigation", Model.IdeaSummary.IdeaId ); %>
    <% using (Html.BeginForm())
       {%>
    <%=Html.AntiForgeryToken() %>
    <div class="mainInner colViewHdr">
        <div class="ideaListItem p10">
            <h1><%=Model.IdeaSummary.IdeaTitle %></h1>
            <div class="ideaStatusBar">
                <div class="floatLeft pr10">
                    <%=Model.IdeaSummary.SubmittedDate.ToString("D", CultureInfo.CreateSpecificCulture("en-US"))%>
                    | by <%=Model.IdeaSummary.Submitter %></div>
            </div>
        </div>
        <h3>
            <%=header%></h3>
        <br clear="all" />
        <div class="errorMessages">
            <%= Html.ValidationSummary(Stimulus360.Resources.Stimulus360.ValidationSummary_MandatoryDetails )%></div>
        <div class="ideaStatusBar">
            <div class="ideaStatus">
                <div>
                    <%Html.RenderPartial("Rating", ratingViewModel); %>
                    <%=Html.Hidden("Rating", Model.Feedback.Rating)%>
                </div>
                <div class="separator">
                </div>
                <div>
                    <%= Html.CheckBox("Favorite", Model.Feedback.Favorite.GetValueOrDefault(false) )%>
                    <label class="inline" for="Favorite">
                        Add To My Favorites</label>
                </div>
            </div>
        </div>
        <ul>
            <li id="foli1">
                <label class="desc" id="title1">
                    Subject</label>
                <div>
                    <%=Html.TextBox("Subject", Model.Feedback.Subject ,new { @tabindex="2", @value="", @size="70", @maxlength="50" } ) %>
                    <%= Html.ValidationMessage("Subject", "*", new { @class = "requiredfield" })%>
                </div>
            </li>
            <li id="foli2">
                <label class="desc" id="description1">
                    Comments</label>
                <div>
                    <%=Html.TextArea("Comments", Model.Feedback.Comments, new { @cols = "70", @rows = "10", @tabindex = "3" })%>
                </div>
            </li>
            <li class="buttons">
                <div class="btnsubmitDiv floatLeft"><input name="submit" class="btnsubmit" type="submit" id="saveForm" value="Submit" />&nbsp;&nbsp;</div>
                <div class="floatLeft"><input name="Cancel" type="button" id="cancelForm" value="Cancel" /></div>
            </li>
        </ul>
        <br clear="all" />
    </div>
    <%=Html.Hidden("selectedRating") %>

    <script language="javascript" type="text/javascript">
        $(document).ready(function() {
            if (($("#IsReadOnly").val()) == "True") {
                {
                    $(".btnsubmitDiv").hide();

                    $("#Favorite").attr("disabled", "disabled");
                    $("#Subject").attr("disabled", "disabled");

                    $("#Comments").attr("disabled", "disabled");
                }
            }
            $(".btnsubmit").click(function() {
                if ($("#selectedRating").val() != "") {
                    $("#Rating").val($("#selectedRating").val());
                }
            });

            $("#cancelForm").click(function() {
                var ideaId = "<%=Model.Feedback.IdeaId  %>";
                var pageIndex = 1;
                window.location = "/Ideas/" + ideaId.toString() + "/Feedback";
            });

            $("#feedbackListTag").click();
        });
    </script>

    <% } %>
</asp:Content>
